import java.util.Scanner;

public class NeighbouringNumbers {
	public static void main(String[] args){
		Integer arraySize = 10;
		Integer[] numbers = new Integer[arraySize];
		Scanner reader = new Scanner(System.in);
		System.out.println(String.format("Enter %s numbers separated by whitespace", arraySize));
		for (Integer inputIndex=0; inputIndex <= numbers.length-1; inputIndex++) {
			numbers[inputIndex] = reader.nextInt();
		}
		Integer maxIndex = numbers.length-1;
		Integer minDist = Integer.MAX_VALUE;
		Integer minDistIndex = Integer.MAX_VALUE;
		
		for (Integer arrayIndex=0; arrayIndex < maxIndex; arrayIndex++) {
			for (Integer xArrayIndex=arrayIndex+1; xArrayIndex <= maxIndex; xArrayIndex++) {
				if ((numbers[arrayIndex] == numbers[xArrayIndex]-1) && (xArrayIndex-arrayIndex < minDist)) {
					minDist=xArrayIndex-arrayIndex;
					minDistIndex=arrayIndex;
				}
			}
		}
		String message = String.format("\nThe index of the element with the closest neighbour is [%s], distance is %s", minDistIndex, minDist);
		System.out.println(message);
	}
}